//1.删除input属性required属性
//2.给button属性值修改type ==button



//3.给按钮做点击事件
$('#login').click(function () {
    console.log("勇敢牛牛不怕困难")
    const username = $('#username').val().trim()
    const password = $('#password').val().trim()
    if (!username || !password) {
        layer.alert('用户名不能为空')
        return
    }
    // console.log('格式正确')
    $.post('http://localhost:8080/api/v1/admin/user/login',
    {username,password},
        function (res) {
        // console.log(res);
    if (res.code !== 200) {
        layer.msg('密码错误')
        return
    }
            localStorage.setItem("token", res.token)
            location.href = "index.html"
  })
})
 